// pages/my/feedback/feedback.js
Page({
  data: {
    message: "",
    fileList: [],
    imgIds: [],
  },
  onLoad: function (options) {

  },
  submit() {
    if (!this.data.message) {
      getApp().globalData.vant.toast("意见反馈内容不能为空");
    } else {
      getApp().globalData.http.feedback({
        feedback: this.data.message,
        imgs: this.data.imgIds.join(",")
      }).then(res => {
        getApp().globalData.vant.toast({
          message: "操作成功",
          duration: 1000,
          onClose: () => {
            wx.navigateBack();
          },
        });
      }).catch(e => {});
    }
  },
  upload(e) {
    getApp().globalData.util.imgsUpload(this, e, this.data.fileList, this.data.imgIds);
  },
  delete(e) {
    console.log(e.detail)
    let i = e.detail.index;
    let fileList = this.data.fileList;
    let imgIds = this.data.imgIds;
    fileList.splice(i, 1);
    imgIds.splice(i, 1);
    this.setData({
      fileList: fileList,
      imgIds: imgIds
    });
  },
})